<?php
namespace app\admin\controller;
use think\captcha\Captcha; //验证码
use think\Db;
class Publics extends Base
{
	public function _initialize()
	{
		// 调用父类前置方法
		parent::_initialize();
	}

	/**
	 * 左侧菜单
	 */
	public function navs()
	{
	    $admin = session('admin');

        $admin_id = $admin['id'];
        $qx=db::name('admin')->where('id',$admin_id)->value('qx');
        if(!empty($qx)){
            $qx=explode(',',$qx);
        }else{
            $qx=[];
        }
        
	    $result=[];
	    $result[]=[
				'id' => 0,
				'title' => '数据概况',
				'icon' => 'layui-icon layui-icon-console',
				'type' => 1,
				'href' => url('Index/welcome'),
			];
        if($admin_id==1 || $admin_id == 5){
            $result[]=[
                'id' => 'showinfo',
                'title' => '数据明细',
                'icon' => 'layui-icon layui-icon-console',
                'type' => 1,
                'href' => url('Index/show'),
            ];
        }
	    if(in_array(1,$qx)||$admin_id==1){
	    $result[]=[
				'id' => 'service',
				'title' => '项目管理',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
					[
						'id' => 'service_index',
						'title' => '项目列表',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Service/index')
					],
					[
						'id' => 'service_class',
						'title' => '项目分类',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('service_class/index')
					]
				]
			];
	    }
	    if(in_array(2,$qx)||$admin_id==1){
		$result[]=[
                'id' => 'proxy',
                'title' => '城市管理',
                'icon' => 'layui-icon layui-icon-template-1',
                'type' => 0,
                'href' => '',
                'children' => [
                    [
                        'id' => 'proxy_index',
                        'title' => '子公司',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('Proxy/index')
                    ],
                    [
                        'id' => 'proxy_index2',
                        'title' => '代理商',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('Proxy/index2')
                    ]
                ]
            ];
	    }
	    if(in_array(3,$qx)||$admin_id==1){
        $result[]=[
				'id' => 'techn',
				'title' => '技师管理',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
				    [
						'id' => 'techn_index',
						'title' => '技师列表',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Techn/index')
					],
					[
						'id' => 'techn_apply_index',
						'title' => '技师审核',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Technapply/index')
					],
                    [
                        'id' => 'techn_move',
                        'title' => '技师迁证',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('Technmove/index')
                    ],
					[
						'id' => 'techn_level_index',
						'title' => '技师等级',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Technlevel/index')
					],
					
				]
			];
	    }
	    if(in_array(4,$qx)||$admin_id==1|| $admin_id == 5){
		$result[]=[
                'id' => 'order',
                'title' => '订单管理',
                'icon' => 'layui-icon layui-icon-template-1',
                'type' => 0,
                'href' => '',
                'children' => [
                    [
                        'id' => 'order_index',
                        'title' => '订单列表',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('order/index')
                    ],
                    
                    [
                        'id' => 'reason_index',
                        'title' => '退款标签',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('reason/index')
                    ],
                    [
                        'id' => 'from_index',
                        'title' => '问卷标签',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('from/index')
                    ],
                ]
            ];
	    }
	    if(in_array(5,$qx)||$admin_id==1){
        $result[]=[
				'id' => 'slide',
				'title' => '轮播图片',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
					[
						'id' => 'slide_index',
						'title' => '图片列表',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Slide/index')
					]
				]
			];
	    }
	    if(in_array(6,$qx)||$admin_id==1){
		    $site=[
				'id' => 'site',
				'title' => '系统设置',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
					[
						'id' => 'area_index',
						'title' => '城市开通',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Area/index')
					],
                    [
                        'id' => 'shuju_index',
                        'title' => '数据设置',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('hottback/index')
                    ],
					[
						'id' => 'set_index',
						'title' => '网站设置',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('set/index')
					],
					[
						'id' => 'chefei_index',
						'title' => '车费设置',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('chefei/index')
					],
                    [
                        'id' => 'send_email',
                        'title' => '下单消息通知',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('email/index')
                    ],
					[
						'id' => 'admin_index',
						'title' => '管理员列表',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('admin/index')
					],

//					[
//						'id' => 'basedata_index',
//						'title' => '数据概况',
//						'icon' => 'layui-icon layui-icon-template-1',
//						'type' => 1,
//						'openType' => '_iframe',
//						'href' => url('basedata/index')
//					],
//					[
//						'id' => 'basedata_techn',
//						'title' => '技师数据(前20)',
//						'icon' => 'layui-icon layui-icon-template-1',
//						'type' => 1,
//						'openType' => '_iframe',
//						'href' => url('basedata/techn')
//					],
//					[
//						'id' => 'basedata_user',
//						'title' => '用户数据(前20)',
//						'icon' => 'layui-icon layui-icon-template-1',
//						'type' => 1,
//						'openType' => '_iframe',
//						'href' => url('basedata/user')
//					],
					
				]
			];
			if($admin_id!=1){
			    unset($site['children'][count($site['children'])-1]);
			}
			$result[]=$site;
	    }
	    if(in_array(7,$qx)||$admin_id==1){
		$result[]=[
				'id' => 'market',
				'title' => '营销管理',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
					[
						'id' => 'coupon_index',
						'title' => '优惠券',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Coupon/index')
					],
                    [
                        'id' => 'coupon_send',
                        'title' => '优惠券派发',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('Coupon/send')
                    ],
                    [
                        'id' => 'coupon_send_list',
                        'title' => '优惠券记录',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('Coupon/send_list')
                    ],
					[
						'id' => 'balance_rechange_index',
						'title' => '充值设置',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('balance_rechange/index')
					],
					[
						'id' => 'user_rechange_list',
						'title' => '充值列表',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('user/rechange_list')
					],
                    [
                        'id' => 'mark_index',
                        'title' => '充值券列表',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('Mark/index')
                    ],
                    [
                        'id' => 'send_message',
                        'title' => '推广短信发送',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('SendMessage/index')
                    ],
				]
			];
	    }
	    if(in_array(8,$qx)||$admin_id==1){
		$result[]=[
				'id' => 'finance',
				'title' => '财务',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
					[
						'id' => 'moneycash_index',
						'title' => '技师提现',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Moneycash/index')
					],
                    [
                        'id' => 'moneycash_log',
                        'title' => '技师转账记录',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('moneycash/zz_log')
                    ],
					[
						'id' => 'yongjin_index',
						'title' => '渠道提现',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('yongjin/index')
					],
                    [
                    'id' => 'yongjin_log',
                    'title' => '渠道转账记录',
                    'icon' => 'layui-icon layui-icon-template-1',
                    'type' => 1,
                    'openType' => '_iframe',
                    'href' => url('yongjin/yj_log')
                ],
				]
			];
	    }
	    if(in_array(9,$qx)||$admin_id==1){
		$result[]=[
				'id' => 'market',
				'title' => '我的渠道',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
                    [
                        'id' => 'qudao',
                        'title' => '渠道申请',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('Qudao/index')
                    ],
					[
						'id' => 'techn_yjindex',
						'title' => '我的团队',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('Techn/yjindex')
					],
					[
						'id' => 'user_index',
						'title' => '我的客户',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('user/index')
					],
					[
						'id' => 'balance_index',
						'title' => '渠道明细',
						'icon' => 'layui-icon layui-icon-template-1',
						'type' => 1,
						'openType' => '_iframe',
						'href' => url('balance/index')
					]
				]
			];
	    }
	    if(in_array(10,$qx)||$admin_id==1){
		$result[]=[
				'id' => 'market',
				'title' => '售后管理',
				'icon' => 'layui-icon layui-icon-template-1',
				'type' => 0,
				'href' => '',
				'children' => [
				    [
                        'id' => 'orderss_index',
                        'title' => '订单申诉',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('orderss/index')
                    ],
                    [
                        'id' => 'from_index',
                        'title' => '投诉建议',
                        'icon' => 'layui-icon layui-icon-template-1',
                        'type' => 1,
                        'openType' => '_iframe',
                        'href' => url('user/fk')
                    ],
				]
			];
	    }
// 		$result = [
// 			[
// 				'id' => 0,
// 				'title' => '工作空间',
// 				'icon' => 'layui-icon layui-icon-console',
// 				'type' => 1,
// 				'href' => url('Index/welcome'),
// 			],
// 			[
// 				'id' => 'service',
// 				'title' => '服务管理',
// 				'icon' => 'layui-icon layui-icon-template-1',
// 				'type' => 0,
// 				'href' => '',
// 				'children' => [
// 					[
// 						'id' => 'service_index',
// 						'title' => '服务列表',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Service/index')
// 					],
// 					[
// 						'id' => 'service_class',
// 						'title' => '分类列表',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('service_class/index')
// 					]
// 				]
// 			],
// 			[
//                 'id' => 'proxy',
//                 'title' => '机构管理',
//                 'icon' => 'layui-icon layui-icon-template-1',
//                 'type' => 0,
//                 'href' => '',
//                 'children' => [
//                     [
//                         'id' => 'proxy_index',
//                         'title' => '机构列表',
//                         'icon' => 'layui-icon layui-icon-template-1',
//                         'type' => 1,
//                         'openType' => '_iframe',
//                         'href' => url('Proxy/index')
//                     ]
//                 ]
//             ],
// 			[
// 				'id' => 'techn',
// 				'title' => '技师管理',
// 				'icon' => 'layui-icon layui-icon-template-1',
// 				'type' => 0,
// 				'href' => '',
// 				'children' => [
// 				    [
// 						'id' => 'techn_index',
// 						'title' => '技师列表',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Techn/index')
// 					],
// 					[
// 						'id' => 'techn_apply_index',
// 						'title' => '技师审核',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Technapply/index')
// 					],
// 					[
// 						'id' => 'techn_level_index',
// 						'title' => '技师等级',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Technlevel/index')
// 					],
					
// 				]
// 			],
// 			[
//                 'id' => 'order',
//                 'title' => '订单管理',
//                 'icon' => 'layui-icon layui-icon-template-1',
//                 'type' => 0,
//                 'href' => '',
//                 'children' => [
//                     [
//                         'id' => 'order_index',
//                         'title' => '订单列表',
//                         'icon' => 'layui-icon layui-icon-template-1',
//                         'type' => 1,
//                         'openType' => '_iframe',
//                         'href' => url('order/index')
//                     ],
//                     [
//                         'id' => 'orderss_index',
//                         'title' => '申诉列表',
//                         'icon' => 'layui-icon layui-icon-template-1',
//                         'type' => 1,
//                         'openType' => '_iframe',
//                         'href' => url('orderss/index')
//                     ],
//                     [
//                         'id' => 'reason_index',
//                         'title' => '退款原因',
//                         'icon' => 'layui-icon layui-icon-template-1',
//                         'type' => 1,
//                         'openType' => '_iframe',
//                         'href' => url('reason/index')
//                     ],
//                     [
//                         'id' => 'from_index',
//                         'title' => '用户来源',
//                         'icon' => 'layui-icon layui-icon-template-1',
//                         'type' => 1,
//                         'openType' => '_iframe',
//                         'href' => url('from/index')
//                     ],
//                 ]
//             ],
// 			[
// 				'id' => 'slide',
// 				'title' => '轮播图片',
// 				'icon' => 'layui-icon layui-icon-template-1',
// 				'type' => 0,
// 				'href' => '',
// 				'children' => [
// 					[
// 						'id' => 'slide_index',
// 						'title' => '轮播列表',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Slide/index')
// 					]
// 				]
// 			],
// 			[
// 				'id' => 'site',
// 				'title' => '站点设置',
// 				'icon' => 'layui-icon layui-icon-template-1',
// 				'type' => 0,
// 				'href' => '',
// 				'children' => [
// 				    [
// 						'id' => 'admin_index',
// 						'title' => '管理员列表',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('admin/index')
// 					],
// 					[
// 						'id' => 'area_index',
// 						'title' => '地区列表',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Area/index')
// 					],
// 					[
// 						'id' => 'set_index',
// 						'title' => '网站设置',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('set/index')
// 					],
// 					[
// 						'id' => 'chefei_index',
// 						'title' => '车费设置',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('chefei/index')
// 					]
// 				]
// 			],
// 			[
// 				'id' => 'market',
// 				'title' => '营销',
// 				'icon' => 'layui-icon layui-icon-template-1',
// 				'type' => 0,
// 				'href' => '',
// 				'children' => [
// 					[
// 						'id' => 'coupon_index',
// 						'title' => '优惠券',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Coupon/index')
// 					],
// 					[
// 						'id' => 'balance_rechange_index',
// 						'title' => '充值设置',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('balance_rechange/index')
// 					]
// 				]
// 			],
// 			[
// 				'id' => 'finance',
// 				'title' => '财务',
// 				'icon' => 'layui-icon layui-icon-template-1',
// 				'type' => 0,
// 				'href' => '',
// 				'children' => [
// 					[
// 						'id' => 'moneycash_index',
// 						'title' => '提现申请',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Moneycash/index')
// 					]
// 				]
// 			],
// 			[
// 				'id' => 'market',
// 				'title' => '我的渠道',
// 				'icon' => 'layui-icon layui-icon-template-1',
// 				'type' => 0,
// 				'href' => '',
// 				'children' => [
// 					[
// 						'id' => 'techn_yjindex',
// 						'title' => '我的团队',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('Techn/yjindex')
// 					],
// 					[
// 						'id' => 'balance_index',
// 						'title' => '渠道财务',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('balance/index')
// 					],
// 					[
// 						'id' => 'yongjin_index',
// 						'title' => '提现申请',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('yongjin/index')
// 					],
// 					[
// 						'id' => 'user_index',
// 						'title' => '我的客户',
// 						'icon' => 'layui-icon layui-icon-template-1',
// 						'type' => 1,
// 						'openType' => '_iframe',
// 						'href' => url('user/index')
// 					]
// 				]
// 			],
// 		];
		echo json_encode($result);
	}

	/**
	 * 验证码
	 */
	public function captcha()
	{
	    $config =    [
            // 验证码位数
            'length'      =>    4,   
           
           
        ];
		$captcha = new Captcha($config);
		$captcha->codeSet = '0123456789'; 
		return $captcha->entry();
	}

	/**
	 * 用户登录
	 */
	public function login()
	{
		$result['code'] = -1;
		$result['msg'] = "非法请求";
		if(request()->isPost())
		{
			$params = input(); //接收post参数
			$validate = $this->validate(
				$params,
				[
					'username' => 'require',
					'password' => 'require',
					'captcha'  => 'require'
				],
				[
					'username.require' => '请填写用户名',
					'password.require' => '请填写密码',
					'captcha.require'  => '请填写验证码',
				]
			);
			if(true !== $validate)
			{
				echo json_encode(['code' => -1, 'msg' => $validate]);
				exit();
			}
			//验证验证码是否正确
			$captcha = new Captcha();
			if(!$captcha->check($params['captcha']))
			{
				echo json_encode(['code' => -1, 'msg' => '验证码不正确']);
				exit();
			}
			//查询用户
			$info = Db::name('admin')->where(['username' => $params['username']])->find();
			//判断是否有该用户
			if(empty($info))
			{
			   	echo json_encode(['code' => -1, 'msg' => '用户不存在']);
			   	exit();
			}
			//判断密码是否正确
			if($info['password'] != CheckMd5($params['password'],$info['salt']))
			{
				echo json_encode(['code' => -1, 'msg' => '密码不正确']);
				exit();
			}
			//校验成功
			//session存储
			$admin['id']       = $info['id'];
			$admin['username'] = $info['username'];
			session('admin', $admin);
			// 返回数据,更新数据库
			$session_data = session('admin');
			if(!empty($session_data))
			{
				$result['code'] = 0;
				$result['msg'] = "登录成功";
			}else
			{
        
				// 失败
				session('admin', null);
				$result['code'] = -1;
				$result['msg'] = "登录失败";
			}
			echo json_encode($result);
		}else
		{
			return $this->fetch();
		}
	}

	/**
	 * 退出登录
	 */
	public function logout()
	{
		session('admin', null);
		$this->redirect('Publics/login');
	}

	/**
	 * 修改密码
	 */
	public function edit_password()
	{
		$result['code'] = -1;
		$result['msg'] = "非法请求";
		if(request()->isPost())
		{
			//登录校验
			$this->IsLogin();
			$params = input(); //接收post参数
			$params['admin'] = $this->admin;
			//dump($params);
			$validate = $this->validate(
				$params,
				[
					'oldpassword' => 'require',
					'newpassword' => ['require', 'regex' => '/^(?=.*\d)(?=.*[a-z])(?=.*[!-\/:-@\[-`{-~])[!-~]{8,20}$/i'],
					'respassword' => 'require|confirm:newpassword'
				],
				[
					'oldpassword.require' => '请填写原始密码',
					'newpassword.require' => '请填写新密码',
					'newpassword.regex'   => '新密码必须为8-20位并包含字母、数字、特殊符号',
					'respassword.require' => '请填写确认密码',
					'respassword.confirm' => '新密码与确认密码不一致'
				]
			);
			if(true !== $validate)
			{
				echo json_encode(['code' => -1, 'msg' => $validate]);
				exit();
			}
			//查询用户是否存
			$info = Db::name('admin')->where(['id' => $params['admin']['id']])->find();
			if(empty($info))
			{
				echo json_encode(['code' => -1, 'msg' => '该用户不存在']);
				exit();
			}
			//判断原始密码是否正确
			if($info['password'] != CheckMd5($params['oldpassword'],$info['salt']))
			{
				echo json_encode(['code' => -1, 'msg' => '原始密码不正确']);
				exit();
			}
			$data['salt']     = GetRandomStr(6);
			$data['password'] = CheckMd5($params['newpassword'],$data['salt']);
			$data['upd_time'] = time();
			if(Db::name('admin')->where(['id' => $info['id']])->update($data))
			{
				session('admin', null);
				$result['code'] = 0;
				$result['msg'] = "密码修改成功";
			}else
			{
				$result['code'] = -1;
				$result['msg'] = "密码修改失败";
			}
			echo json_encode($result);
		}else
		{
			return $this->fetch();
		}
	}
}